package com.homework;

/**
 * @Author 小闽
 * @Date 2024/9/22 11:33
 * @PackageName: com.homework
 * @ClassName: HomeWork08
 * @Description: 练习08
 * @Version 1.0
 */
public class HomeWork08 {
    public static void main(String[] args) {
        /**
         * 枚举类
         * 1. 创建一个Color枚举类
         * 2. 有RED,BLUE,BLACK,YELLOW,GREEN这五个枚举类/对象
         * 3. Color有三个属性redValue,greenValue,blueValue,
         * 4. 创建构造方法，参数包括这三个属性
         * 5. 每个枚举值都要给这三个属性赋值，三个属性对应的值分别是
         * 6. red:255,0,0 blue: 0,0,255 black: 0,0,0 yellow: 255,255,0 green: 0,255,0
         * 7. 定义接口，里面有方法show, 要求Color实现该接口
         * 8. show方法中显示三属性的值
         * 9. 将枚举对象在switch语句中匹配使用
         */
        Color blue = Color.BLUE;
        switch (blue) {
            case GREEN:
                System.out.println("输出绿色");
                break;
            case Red:
                System.out.println("输出红色");
                break;
            case YELLOW:
                System.out.println("输出黄色");
                break;
            case BLACK:
                System.out.println("输出黑色");
            case BLUE:
                System.out.println("输出蓝色");
                break;
            default:
                System.out.println("其他颜色");
        }
    }
}

interface ColorInterface {
    void show();
}

enum Color implements ColorInterface {
    Red(255, 0, 0),
    BLUE(0, 0, 255),
    BLACK(0, 0, 0),
    YELLOW(255, 255, 0),
    GREEN(0, 255, 0);
    private int reaValue;
    private int greenValue;
    private int blueValue;

    Color(int reaValue, int greenValue, int blueValue) {
        this.reaValue = reaValue;
        this.greenValue = greenValue;
        this.blueValue = blueValue;
    }

    @Override
    public void show() {
        System.out.println("属性值为：" + reaValue + "," + greenValue + "," + blueValue);
    }
}